<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var shiftingLetters = function (s, shifts) {
      let arr = 'abcdefghijklmnopqrstuvwxyz'.split('')
      let index = 0;
      let ans = []

      for (let i = s.length - 1; i >= 0; i--) {
        index += shifts[i]
        ans.push(arr[(s[i].charCodeAt() + index - 97) % 26])
      }
      return ans.reverse().join('');
    };
    console.log(shiftingLetters(s = "aaa", shifts = [1, 2, 3]));
  </script>
</body>

</html>